<%-- 
/*
Assignment 1
Class ID        : SE0691
Group           : 1
Due Date        : 20 November 2012
I declare that this assignment is my own work
in accordance with FPT Policy.
*/
--%>

<%@page import="edu.fpt.hib.Users"%>
<%@page import="edu.fpt.dal.ApartmentDAL"%>
<%@page import="edu.fpt.hib.Apartment"%>
<%@page import="edu.fpt.hib.UserEntity"%>
<%@page import="edu.fpt.dal.UsersDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Editing user</title>
        <style type="text/css"> <!--@import url("../style.css");--></style>
        <script>function goBack()  {  window.history.back()  }</script>
    </head>
    <body>
        <%@include file="template/header.jsp" %>
        <div id="page">

            <%
                if (UsersDAL.getUsersHQL(request.getParameter("userid")).getUserId() == null) {
            %>
            User not found!
            <% } else {
                //Users user = UsersDAL.getUsersHQL(request.getParameter("userid"));
                Users user = UsersDAL.getUsersHQL(request.getParameter("userid"));
                Apartment apart = ApartmentDAL.getApartmentByUserHQL(user.getUserId());
                if (request.getParameter("error") == null) {
            %>
            <h2 class="title">Editing of : <%=user.getUserFullName()%></h2>
            <form method="post" action="../EditUser">
                <table border="0">
                    <tr>
                        <td>Username:</td>
                        <td><input type="text" value="<%=user.getUserId()%>" disabled="" name="username">
                            <input type="hidden" value="<%=user.getUserId()%>" name="userid"></td>
                    </tr>
                    <tr>
                        <td>Password:</td>
                        <td><input class="searchinput" type="password" value="<%=user.getUserPass()%>" name="password" required=""></td>
                    </tr>
                    <tr>
                        <td>Full Name:</td>
                        <td><input class="searchinput" type="text" value="<%=user.getUserFullName()%>" name="fullname" required="">
                            <input type="hidden" name="isEdit" value="change"></td>
                    </tr>

                </table>
                <input class="searchsubmit" type="submit" name="Change">
                <input class="searchsubmit" type="reset" name="Reset">
                <input class="searchsubmit" type='button' value='Back' onclick='goBack()'>
            </form>
            <%} else {%>
            <h1><%=request.getParameter("error")%></h1>
            <%}
                }%>
        </div>
        <%@include file="template/footer.jsp" %>
    </body>
</html>
